package com.atguigu.tingshu.user.rpc;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.user.service.VipServiceConfigService;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @BelongsProject: tingshu-backend
 * @BelongsPackage: com.atguigu.tingshu.user.rpc
 * @Author: coilk
 * @CreateTime: 2025-03-18  08:43
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/api/inner/userinfo")
public class UserInfoRpcController {

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private VipServiceConfigService vipServiceConfigService;

    @GetMapping("/getUserInfo/{userId}")
    Result<UserInfoVo> getUserInfo(@PathVariable(value = "userId") Long userId) {
        UserInfoVo userInfoVo = userInfoService.getUserInfo(userId);
        return Result.ok(userInfoVo);
    }

    @GetMapping("/getUserPaidAlbumTrack/{userId}/{albumId}")
    Result<Map<Long, String>> getUserPaidAlbumTrack(@PathVariable(value = "userId") Long userId,
                                                    @PathVariable(value = "albumId") Long albumId) {
        Map<Long, String> map = userInfoService.getUserPaidAlbumTrack(userId, albumId);
        return Result.ok(map);
    }

    @GetMapping("/getUserPaidAlbum/{userId}/{albumId}")
    Result<Boolean> getUserPaidAlbum(@PathVariable(value = "userId") Long userId,
                                     @PathVariable(value = "albumId") Long albumId) {
        Boolean isPaidAlbum = userInfoService.getUserPaidAlbum(userId, albumId);
        return Result.ok(isPaidAlbum);
    }

    @GetMapping("/getVipConfigById/{itemId}")
    Result<VipServiceConfig> getVipConfigById(@PathVariable(value = "itemId") Long itemId) {
        VipServiceConfig vipServiceConfig = vipServiceConfigService.getById(itemId);
        return Result.ok(vipServiceConfig);
    }
}
